﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Core.Support;
using Microsoft.SharePoint;
using MS.InformationManagement.DAL.DocumentCenter;
using MS.InformationManagement.Support.Constants;

namespace MS.InformationManagement.BLL.ReceivedDocuments
{
    public class DeletePrintedDocumentsCommand : IBaseCommand
    {

        #region fields

        IList<int> _selectedItems;
        IEnumerable<DocumentoImpreso> _printedDocuments;

        #endregion

        #region Constructors

        public DeletePrintedDocumentsCommand(IList<int> selectedItems)
        {
            _selectedItems = selectedItems;
        }

        #endregion

        #region Command Methods

        public void Execute()
        {
            using (var dc = new DCDocumentCenterDataContext(SPContext.Current.Web.Url))
            {
                _printedDocuments = Support.GetPrintedAttachedEntities(dc,_selectedItems);
                dc.DocumentosImpresos.DeleteAllOnSubmit(_printedDocuments);
                dc.SubmitChanges();
            }
        }

        public void Undo()
        {
            //TODO:Create deleted items
        }

        #endregion

    }
}
